from appium import webdriver
from appium.options.common import AppiumOptions

from wework_frame.base.base_page import BasePage


class WeWorkApp(BasePage):
    def start_app(self):
        caps = {
            "platformName": "Android",
            "deviceName": "127.0.0.1:7555",
            "appium:appPackage": "com.tencent.wework",
            "appium:appActivity": ".launch.LaunchSplashActivity",
            "appium:automationName": "uiautomator2",
            "appium:noReset": True
        }

        self.driver = webdriver.Remote(
            "http://127.0.0.1:4723/wd/hub",
            options=AppiumOptions().load_capabilities(caps)
        )

        self.driver.implicitly_wait(15)
        return self

    def quit_app(self):
        self.driver.quit()

    def goto_main(self):
        from wework_frame.page.main_page import MainPage
        return MainPage(self.driver)
